#include "Global.h"
#include "IVisitor.h"

Global::Global(const NameTokList& names, const exprTypePtr& value, int nodeId):
    stmtType(nodeId),
    _names(names),
    _value(value)
{
}
    
Global::~Global()
{
    _names.clear();
}
    
Ast::AstTypes Global::type() const
{
    return Ast::Global;
}
    

NameTokList Global::names()
{
    return _names;
}

void Global::setNames(const NameTokList& names)
{
    _names = names;
}

exprTypePtr Global::value()
{
    return _value;
}

void Global::setValue(const exprTypePtr& value)
{
    _value = value;
}

    
QString Global::toString() const
{
    return QString("Global[names=%1, value=%2]").
                arg(_names.toString()).
                arg(_value ? _value->toString():"");
}
    
void Global::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitGlobal(node.dynamicCast<Global>());
}
    
void Global::traverse(IVisitor* visitor)
{
    _names.traverse(visitor);
    if (_value != NULL)
        _value->accept(visitor, _value);
}